package com.zzxy.spring34.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Component
@Aspect

public class MyAspectJ {
    @Before(value = "execution(* com.zzxy.spring34.service.impl.*.*(..))")
    public void myBefore(JoinPoint joinpoint){
        System.out.println("before method:"+joinpoint.getSignature().getName());
                System.out.println("my before ...");
    }
    public void myAfter(JoinPoint joinpoint){
        System.out.println("after method :"+ joinpoint.getSignature().getName());
        System.out.println("my after ...");
    }
    @Around(value = "execution(* com.zzxy.spring34.service.impl.*.*(..))")
    public Object myAround(ProceedingJoinPoint pjp) throws Throwable{
        System.out.println("before aroudn:");
        Object obj = pjp.proceed();
        System.out.println("after aroudn:");
        return obj;
    }
    public void myAfterReturning(JoinPoint joinpoint,Object ret){
        System.out.println("after returing method:"+ joinpoint.getSignature().getName()+"return:"+ret);

    }
    public  void myThrowing(JoinPoint joinpoint,Throwable e){
        System.out.println("my throwing "+e.getMessage());
        
    }
    }
